package logic

import (
	"context"
	"fmt"

	__ "user/pb"
	"user/rpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetUserInfoLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserInfoLogic {
	return &GetUserInfoLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GetUserInfoLogic) GetUserInfo(in *__.GetUserReq) (*__.GetUserResp, error) {
	// todo: add your logic here and delete this line
	if userInfo, exists := UserMap[in.Id]; exists {
		return &__.GetUserResp{
			Id:    userInfo.Id,
			Name:  userInfo.Name,
			Phone: userInfo.Phone,
		}, nil

	}
	return nil, fmt.Errorf("用户不存在")
}
